package no.ntnu.fp.gui;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.event.*;
import java.io.IOException;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import no.ntnu.fp.model.Appointment;


/**
 * Klasse for å legge til ny avtale
 *  
 * @author Kristian
 */

public class GUINewAppointment extends javax.swing.JFrame implements ActionListener {

	private JLabel loggedInAsLabel;
	private JLabel appointmentLabel;
	private JLabel appointmentTimeLabel;
	private JLabel appointmentDateLabel;
	private JLabel availableRoomLabel;
	private JLabel addParticipantsLabel;

	private JButton addTypeOfMeetingButton;
	private JButton chooseRoomButton;
	private JButton addAppointmentDate;
	private JButton addParticipantsButton;
	private JButton addAppointmentButton;
	private JButton appointmentTimeButton;

	private JTextField appointmentTimeField;
	private JTextField appointmentDateField;

	private JComboBox availableRoomList;
	private JComboBox participantsList;
	private JComboBox appointmentList;

	private Appointment app;
	
	/**
	 * Main method
	 */
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				GUINewAppointment inst = new GUINewAppointment();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}

	public GUINewAppointment() {
		super();
		initGUI();
		app = new Appointment();
	}

	private void initGUI() {
		try {
			GridBagLayout thisLayout = new GridBagLayout();
			thisLayout.rowWeights = new double[] {0.1, 0.1, 0.1, 0.1};
			thisLayout.rowHeights = new int[] {7, 7, 7, 7};
			thisLayout.columnWeights = new double[] {0.1, 0.1, 0.1, 0.1};
			thisLayout.columnWidths = new int[] {7, 7, 7, 7};
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				loggedInAsLabel = new JLabel();
				getContentPane().add(loggedInAsLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10, 10, 0, 0), 0, 0));
				loggedInAsLabel.setText("Logget inn som: ");
			}
			{
				//Liste med de forskjellige møtetypene
				ComboBoxModel appointmentListModel = 
					new DefaultComboBoxModel(
							new String[] { "Item One", "Item Two" });
				appointmentList = new JComboBox();
				getContentPane().add(appointmentList, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0));
				appointmentList.setModel(appointmentListModel);
				appointmentList.setPreferredSize(new java.awt.Dimension(100, 23));
			}
			{
				//Label for de forskjellige møtetypene
				appointmentLabel = new JLabel();
				getContentPane().add(appointmentLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
				appointmentLabel.setText("Velg type");
			}
			{
				//Legg til deltaker label
				addParticipantsLabel = new JLabel();
				getContentPane().add(addParticipantsLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 10, 0, 0), 0, 0));
				addParticipantsLabel.setText("Legg til deltakere");
			}
			{
				//Deltaker liste
				ComboBoxModel participantsListModel = 
					new DefaultComboBoxModel(
							new String[] { "Item One", "Item Two" });
				participantsList = new JComboBox();
				getContentPane().add(participantsList, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0));
				participantsList.setModel(participantsListModel);
				participantsList.setPreferredSize(new java.awt.Dimension(100, 23));
			}
			{
				//Leggg til møtetype knapp
				addTypeOfMeetingButton = new JButton();
				getContentPane().add(addTypeOfMeetingButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				addTypeOfMeetingButton.setText("Legg til");
				addTypeOfMeetingButton.setPreferredSize(new java.awt.Dimension(70, 23));
			}
			{
				//Legg til deltaker knapp
				addParticipantsButton = new JButton();
				getContentPane().add(addParticipantsButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0));
				addParticipantsButton.setText("Legg til");
				addParticipantsButton.setPreferredSize(new java.awt.Dimension(70, 23));
			}
			{
				//Ledige rom label
				availableRoomLabel = new JLabel();
				getContentPane().add(availableRoomLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
				availableRoomLabel.setText("Ledige rom: ");
			}
			{
				//Ledige rom liste
				ComboBoxModel availableRoomListModel = 
					new DefaultComboBoxModel(
							new String[] { "Item One", "Item Two" });
				availableRoomList = new JComboBox();
				getContentPane().add(availableRoomList, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				availableRoomList.setModel(availableRoomListModel);
				availableRoomList.setPreferredSize(new java.awt.Dimension(100, 23));
			}
			{
				//Velg rom knapp
				chooseRoomButton = new JButton();
				getContentPane().add(chooseRoomButton, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				chooseRoomButton.setText("Velg rom");
				chooseRoomButton.setPreferredSize(new java.awt.Dimension(70, 23));
			}
			{
				//Møtedato label
				appointmentDateLabel = new JLabel();
				getContentPane().add(appointmentDateLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
				appointmentDateLabel.setText("Dato for møtet");
			}
			{
				//Møtedato felt
				appointmentDateField = new JTextField();
				getContentPane().add(appointmentDateField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				appointmentDateField.setPreferredSize(new java.awt.Dimension(100, 23));
				appointmentDateField.setText("DD.MM.YYYY");
			}
			{
				//Legg til møtedato knapp
				addAppointmentDate = new JButton();
				getContentPane().add(addAppointmentDate, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				addAppointmentDate.setText("Legg til");
				addAppointmentDate.setPreferredSize(new java.awt.Dimension(70, 23));
			}
			{
				//Møtetidspunkt label
				appointmentTimeLabel = new JLabel();
				getContentPane().add(appointmentTimeLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 10, 0, 0), 0, 0));
				appointmentTimeLabel.setText("Møtetidspunkt ");
			}
			{
				//Møtetidspunktfelt
				appointmentTimeField = new JTextField();
				getContentPane().add(appointmentTimeField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0));
				appointmentTimeField.setText("HH:MM");
				appointmentTimeField.setPreferredSize(new java.awt.Dimension(100, 23));
			}
			{
				//Møtetidspunkt knapp
				appointmentTimeButton = new JButton();
				getContentPane().add(appointmentTimeButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(20, 0, 0, 0), 0, 0));
				appointmentTimeButton.setText("Legg til");
				appointmentTimeButton.setPreferredSize(new java.awt.Dimension(70, 23));
			}
			{
				//Legg til møte
				addAppointmentButton = new JButton();
				getContentPane().add(addAppointmentButton, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
				addAppointmentButton.setText("Legg til i kalender");
				addAppointmentButton.setPreferredSize(new java.awt.Dimension(123, 23));
			}
			pack();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Denne metoden finner hva brukeren har proevd paa, og handler deretter.
	 */
	public void actionPerformed(ActionEvent evt) {

		Object action = evt.getSource();
		if(action==addTypeOfMeetingButton){
			
		}
		else if(action==chooseRoomButton){
			
		}
		else if(action==addAppointmentDate){
			
		}
		else if(action==addParticipantsButton){
			
		}
		else if(action==addAppointmentButton){
			
		}
		else if(action==appointmentTimeButton){
			
		}
	}
}
